package com.xiaoqi.store.entity;

import lombok.*;

import java.util.Date;
import java.util.Objects;

/**
 * @Author Rookie Coder
 * @Description 购物车实体类
 * @Date
 **/
public class CartEntity extends BaseEntity {

    private Integer cid;// '购物车数据id',
    private Integer uid;// '用户id',
    private Integer pid;//'商品id',
    private Long price;// '加入时商品单价',
    private Integer num;//'商品数量',

    public CartEntity(String createdUser, Date createdTime, String modifiedUser, Date modifiedTime, Integer cid, Integer uid, Integer pid, Long price, Integer num) {
        super(createdUser, createdTime, modifiedUser, modifiedTime);
        this.cid = cid;
        this.uid = uid;
        this.pid = pid;
        this.price = price;
        this.num = num;
    }

    public CartEntity(Integer cid, Integer uid, Integer pid, Long price, Integer num) {
        this.cid = cid;
        this.uid = uid;
        this.pid = pid;
        this.price = price;
        this.num = num;
    }

    public CartEntity() {
    }

    public Integer getCid() {
        return cid;
    }

    public void setCid(Integer cid) {
        this.cid = cid;
    }

    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public Long getPrice() {
        return price;
    }

    public void setPrice(Long price) {
        this.price = price;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof CartEntity)) return false;
        if (!super.equals(o)) return false;
        CartEntity that = (CartEntity) o;
        return Objects.equals(getCid(), that.getCid()) &&
                Objects.equals(getUid(), that.getUid()) &&
                Objects.equals(getPid(), that.getPid()) &&
                Objects.equals(getPrice(), that.getPrice()) &&
                Objects.equals(getNum(), that.getNum());
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), getCid(), getUid(), getPid(), getPrice(), getNum());
    }

    @Override
    public String toString() {
        return "CartEntity{" +
                "cid=" + cid +
                ", uid=" + uid +
                ", pid=" + pid +
                ", price=" + price +
                ", num=" + num +
                '}';
    }
}
